﻿<phone:PhoneApplicationPage 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
	x:Class="Iridescent.TimetablePage"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait" Orientation="Portrait"
	shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="CourseTemplate">
            <StackPanel Tap="StackPanel_Tap">
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem Header="编辑" Click="EditMenuItem_Click"/>
                        <toolkit:MenuItem Header="删除" Click="DeleteMenuItem_Click"/>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
                <TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeExtraLarge}"/>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding StartTime,Converter={StaticResource TimeConverter}}" d:LayoutOverrides="Width" FontSize="{StaticResource PhoneFontSizeMedium}"/>
                    <TextBlock TextWrapping="Wrap" Text="-" Margin="6,0" FontSize="{StaticResource PhoneFontSizeMedium}"/>
                    <TextBlock Text="{Binding EndTIme,Converter={StaticResource TimeConverter}}" d:LayoutOverrides="Width" FontSize="{StaticResource PhoneFontSizeMedium}"/>
                </StackPanel>
                <TextBlock Text="{Binding Loaction}" FontSize="{StaticResource PhoneFontSizeMedium}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="PivotItemHeaderTemplate">
            <Grid>
                <TextBlock Text="{Binding Day,Converter={StaticResource DayOfWeekConverter}}"/>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="PivotItemContentTemplate">
            <Grid>
                <ListBox ItemTemplate="{StaticResource CourseTemplate}"
                         ItemsSource="{Binding Courses}"/>
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.new.rest.png" Text="New" Click="AppBarNewIconButton_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <controls:Pivot 
            Title="课程表"
            ItemsSource="{Binding CourseListViewModels}"
            SelectedIndex="{Binding SelectedCourseListIndex,Mode=TwoWay}"
            HeaderTemplate="{StaticResource PivotItemHeaderTemplate}"
            ItemTemplate="{StaticResource PivotItemContentTemplate}"/>
    </Grid>
</phone:PhoneApplicationPage>